/*
 * Copyright (c) 2006, 2022, webrx.cn All rights reserved.
 *
 */
package cn.su;

import org.jsoup.Jsoup;

import java.io.IOException;
import java.util.Scanner;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

/**
 * <p>Project: jse2204 - Ex7
 * <p>Powered by webrx On 2022-09-15 15:09:43
 *
 * @author webrx [webrx@126.com]
 * @version 1.0
 * @since 17
 */
public class Ex7 {
    public static void main(String[] args) throws IOException {
        Scanner sc = new Scanner(System.in);
        System.out.print("请输入要检查的IP:");
        String ip  = sc.nextLine();

        String u = "https://www.ip138.com/iplookup.asp?ip="+ip+"&action=2";
        String ts = Jsoup.connect(u).get().toString();

        Pattern p = Pattern.compile("\"ASN归属地\":\"([\u4e00-\u9fa5\s]+)\"");
        Matcher m = p.matcher(ts);
        while(m.find()) {
            System.out.println(m.group(1));
        }
    }
}
